<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    {include file="/layout/scriptload"}
    <title>关注后回复列表</title>
</head>
<body>
<div class="box">
    <section class="content-header">
        <ol class="breadcrumb">
            <li><a><i class="fa fa-dashboard"></i> 关注后回复列表</a></li>
        </ol>
    </section>
    <!-- /.box-header -->
    <section class="content">
    <div class="box-body">
        <div id="example1_wrapper" class="dataTables_wrapper form-inline dt-bootstrap">
            <div class="row">
                <div class="col-sm-12">
                        <div id="example1_filter" class="dataTables_length">
                            <label>
                                <input type="search" id="keyword" class="form-control input-sm" placeholder="回复ID" aria-controls="example1">
                            </label>
                            <button type="button" id="search" class="btn margin" style="background: #18bc9c;color: #ffffff;">搜索</button>
                            <button type="button" onclick="relist()" title="刷新" class="btn bg-aqua margin"><i class="fa fa-refresh"></i></button>
                            <div class="form-group">
                                <label>分类：</label>
                                <select id="select" class="form-control select2" style="width: 120px;">
                                    <option value="" selected="selected">一级分类</option>
                                    {volist name="category" id="v"}
                                    <option value="{$v.id}">{$v.categoryname}</option>
                                    {/volist}
                                </select>
                                <select id="select2" class="form-control select2" style="width: 120px;">
                                    <option selected="selected">二级分类</option>
                                </select>
                            </div>
                        </div>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-12">
                    <table id="example1" class="table table-bordered table-striped dataTable" role="grid" aria-describedby="example1_info">
                        <thead>
                        <tr role="row">
                            <th class="sorting" tabindex="0" aria-controls="example1" rowspan="1" colspan="1" style="width: 190px;">回复ID</th>
                            <th class="sorting" tabindex="0" aria-controls="example1" rowspan="1" colspan="1" style="width: 190px;">一级分类</th>
                            <th class="sorting" tabindex="0" aria-controls="example1" rowspan="1" colspan="1" style="width: 297px;">二级分类</th>
                            <th class="sorting" tabindex="0" aria-controls="example1" rowspan="1" colspan="1" style="width: 361px;">类型</th>
                            <th class="sorting" tabindex="0" aria-controls="example1" rowspan="1" colspan="1" style="width: 361px;">关注后回复</th>
                            <th class="sorting" tabindex="0" aria-controls="example1" rowspan="1" colspan="1" style="width: 190px;">创建时间</th>
                            <th class="sorting" tabindex="0" aria-controls="example1" rowspan="1" colspan="1" style="width: 200px;">内容</th>
                            <th class="sorting" tabindex="0" aria-controls="example1" rowspan="1" colspan="1" style="width: 190px;">操作</th>
                        </tr>
                        </thead>
                        <tbody id="tb">
                       </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
    <!-- /.box-body -->
    </section>
</div>
</body>
<script>
    var _keyword = '';
    var _category = '';
    var _category2 = '';
    $(function(){
        getlist(_keyword);
        $('#search').click(function(){
            table.destroy();
            var keyword = $('#keyword').val();
            getlist(keyword);
        })
        $('#select').change(function(){
            var _id=  $("#select").val();$.ajax({
                type: 'post',
                cache: false,
                url: '{:url("admin/Tencent/getCategoryList")}',
                data: {id: _id},
                success: function(data) {
                    if (data.code == "0") {
                        $("#select2 option").remove();
                        var html = '<option value="">请选择...</option>';
                        $("#select2").append(html);
                        $.each(data.info, function (index, item) {
                            var html = '<option value="' + item.id + '">' + item.categoryname + '</option>';
                            $("#select2").append(html);
                        });
                        table.destroy();
                        getlist(_keyword,_id);
                    }
                }
            });
        })
    })
    $('#select2').change(function(){
        var _id2=  $("#select2").val();
        table.destroy();
        getlist(_keyword,'',_id2);
    })
    function getlist(_keyword,_category,_category2)
    {
        $.ajax({
            type: 'post', cache: false,
            url:'{:url("replymessage/getMessageList")}',
            data: {keyword:_keyword,category:_category,category2:_category2,type:1},
            success: function(data) {
                if(data.code=="0")
                {
                    $("#tb tr").remove();
                    $.each(data.info,function(index,item){
                        var html='<tr role="row" class="odd" id="tr_'+item.id+'">';
                        html+='<td style="vertical-align: middle;">'+item.id+'</td>';
                        html+='<td style="vertical-align: middle;">'+item.category+'</td>';
                        html+='<td style="vertical-align: middle;">'+item.category2+'</td>';
                        if(item.info_type == 1)
                            html+='<td style="vertical-align: middle;color: #449d44;">图文</td>';
                        if(item.info_type == 2)
                            html+='<td style="vertical-align: middle;color: #f1a417;">文本</td>';
                        html+='<td style="vertical-align: middle;">是</td>';
                        html+='<td style="vertical-align: middle;">'+item.createtime+'</td>';
                        html+='<td style="vertical-align: middle;"><a href="#" class="btn bg-aqua" onclick="checkInfo('+item.id+')">查看详情</a></td>';
                        html+='<td style="vertical-align: middle;text-align: center">';
                        html+='<div class="btn-group">';
                        html+=' <button onclick="toedit('+item.id+')" type="button" class="btn" style="background: #18bc9c;color: #ffffff;"><i class="fa fa-edit"></i></button>';
                        html+='</div>';
                        html+='</td>';
                        html+='</tr>';
                        $("#tb").append(html);
                    });
                    table = $('#example1').DataTable({
                        "paging": true,
                        "lengthChange": false,
                        "lengthMenu": [[10],[10]],
                        "searching": false,
                        "ordering": false,
                        "info": true,
                        "language": {
                            "info": "展示第 <span style='color: red;'>_START_</span> 到 <span style='color: red;'>_END_</span> 个 共 <span style='color: red;'>_TOTAL_</span> 个公众号",
                            "paginate": {
                                "previous": "上一页",
                                "next": "下一页"
                            }
                        },
                        "autoWidth": true,
                    });
                }
            },
            error: function() {
                alert("发生系统错误,请与管理员联系！");
            }
        });
    }
    //查看详情
    function checkInfo(_id){
        url = "{:url('replymessage/reply_detail')}" + "?id=" + _id;
        layerWindow('消息回复管理->回复内容详情',url,'40%','60%');
    }
    //编辑账号
    function toedit(_id) {
        url = "{:url('replymessage/editreply')}" + "?id=" + _id;
        layerWindow('消息回复管理->编辑回复消息',url,'40%','75%')
    }
    function relist()
    {
        table.destroy();
        getlist(_keyword);
    }
</script>
</html>